<template>
  <div>
    <div v-for="(item, index) in data" :key="index" class="mg_t10">
      <div class="name pd_l10" @click="item.level == 3 ? chose(item, data) : ''">
        <a-icon :type="item.level == 3 ? 'user' : 'folder'" />
        {{ item.name }}

        <a-icon v-if="item.isSelected" type="check" style="padding-left:14px;" />
      </div>
      <template v-if="item.positionChildList">
        <customTree class="mg_l20" :data="item.positionChildList" @addPosition="addPosition" @minus="minus" />
      </template>
    </div>
  </div>
</template>

<script>
export default {
  name: "CustomTree",

  props: ["data", "users"],
  data() {
    return {
      empy: [],
      chosedUser: []
    };
  },

  methods: {
    chose(item, data) {
      item.isSelected = !item.isSelected;
      if (item.isSelected) {
        this.$emit("addPosition", item);
      } else {
        this.$emit("minus", item);
      }
    },
    addPosition(item) {
      this.$emit("addPosition", item);
    },
    minus(item) {
      this.$emit("minus", item);
    }
  }
};
</script>
<style lang="scss" scoped>
.active {
  background: #6a66f633;
  color: #fff;
}
.name {
  line-height: 32px;
}
</style>
